﻿using SlamDunk.CMS.Model.Base;
using SlamDunk.CMS.Model.ViewModel;

namespace SlamDunk.CMS.Model.DataModel
{
    /// <summary>
    /// 相片
    /// </summary>
    public class Photo : BaseEntity
    {
        #region # 属性

        #region 相册Id —— int AlbumId
        /// <summary>
        /// 相册Id
        /// </summary>
        public int AlbumId { get; set; }
        #endregion

        #region 相片名称 —— string PhotoName
        /// <summary>
        /// 相片名称
        /// </summary>
        public string PhotoName { get; set; }
        #endregion

        #region 描述 —— string Description
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        #endregion

        #region 链接地址 —— string Url
        /// <summary>
        /// 链接地址
        /// </summary>
        public string Url { get; set; }
        #endregion

        #region 图片路径 —— string ImagePath
        /// <summary>
        /// 图片路径
        /// </summary>
        public string ImagePath { get; set; }
        #endregion

        #region 缩略图路径 —— string ThumbPath
        /// <summary>
        /// 缩略图路径
        /// </summary>
        public string ThumbPath { get; set; }
        #endregion

        #region 排序 —— int Sort
        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }
        #endregion

        #region 导航属性 - 相册 —— PhotoAlbum PhotoAlbum
        /// <summary>
        /// 导航属性 - 相册
        /// </summary>
        public virtual PhotoAlbum PhotoAlbum { get; set; }
        #endregion

        #endregion

        #region # 方法

        #region 转换为视图模型 —— PhotoView ToViewModel()
        /// <summary>
        /// 转换为视图模型
        /// </summary>
        /// <returns>视图模型</returns>
        public PhotoView ToViewModel()
        {
            return new PhotoView()
            {
                Id = this.Id,
                AlbumId = this.AlbumId,
                AlbumName = this.PhotoAlbum.AlbumName,
                PhotoAlbum = this.PhotoAlbum,
                PhotoName = this.PhotoName,
                Description = this.Description,
                Url = this.Url,
                ImagePath = this.ImagePath,
                ThumbPath = this.ThumbPath,
                Sort = this.Sort,
                AddTime = this.AddTime.ToString("yyyy-MM-dd HH:mm:ss")
            };
        }
        #endregion

        #endregion
    }
}
